if exists (select 1 from sysobjects where name = 'upd_options' and type = 'P')
begin
   drop procedure upd_options
   print 'Procedure: upd_options deleted ...'
end
go
create procedure upd_options(
  @typin             varchar(30)   = 'Arbeitszeitprotag',
  @wertin            int           = 1,
  @zahlwertin        decimal(15,2) = 8,
  @textwert          varchar(255)  = 'Stunden pro Tag'
)
as
begin
  set nocount on

   if @textwert = '' or @textwert is null select @textwert = textwert from Options where typ = @typin and wert = @wertin

   update Options set
          zahlwert       = @zahlwertin,
          textwert       = @textwert
    where typ            = @typin
      and wert           = @wertin 
--      and textwert       = @textwert
end
go
print 'Procedure: upd_options done ...'
go
grant exec on upd_options to prsadmins with grant option
go
grant exec on upd_options to prsusers
go

